if (select(2, UnitClass("player")) ~= "DEATHKNIGHT") then
    return
end

local function k()
    RuneButtonIndividual1:ClearAllPoints()
    RuneButtonIndividual1:SetPoint("RIGHT", RuneFrame, "CENTER", -89, 0)
    
    RuneButtonIndividual2:ClearAllPoints()
    RuneButtonIndividual2:SetPoint("RIGHT", RuneFrame, "CENTER", -47, 0)
    
    RuneButtonIndividual3:ClearAllPoints()
    RuneButtonIndividual3:SetPoint("RIGHT", RuneFrame, "CENTER", -4.75, 0)
    
    RuneButtonIndividual4:ClearAllPoints()
    RuneButtonIndividual4:SetPoint("LEFT", RuneFrame, "CENTER", 4.75, 0)
    
    RuneButtonIndividual5:ClearAllPoints()
    RuneButtonIndividual5:SetPoint("LEFT", RuneFrame, "CENTER", 47.35, 0)
    
    RuneButtonIndividual6:ClearAllPoints()
    RuneButtonIndividual6:SetPoint("LEFT", RuneFrame, "CENTER", 90.35, 0)
end

local function x(name, i)
    local frame = _G[name..i]
    frame:SetScale(0.35)
    frame.SetScale = function() end
        
    frame:SetParent(RuneFrame)
    frame.SetParent = function() end

    frame:SetHeight(22)
    frame:SetWidth(33)

    frame:EnableMouse(false)
        
    local border = _G[name..i.."Border"]
    border:Hide()
        
    local icon = _G[name..i.."Rune"]
    icon:SetTexCoord(0, 1, 0, 1)
    icon:SetHeight(22)
    icon:SetWidth(33)
        
    local cooldown = _G[name..i.."Cooldown"]
    cooldown:SetAllPoints(icon)
    
    local f = frame:CreateTexture(name..i.."Overlay", "OVERLAY")
    f:SetTexture("Interface\\AddOns\\nRune\\rothars_gloss_texture")
    f:SetParent(frame)
    f:SetTexCoord(0.03, 0.97, 0.03, 0.97)
    f:SetPoint("TOPRIGHT", icon, 1, 1)
    f:SetPoint("BOTTOMLEFT", icon, -1, -1)
end

local addon = CreateFrame("Frame", nil, UIParent)
    
addon:SetScript("OnEvent", function()
    if (event == "PLAYER_REGEN_ENABLED") then
        RuneFrame:SetAlpha(0.5)
    end
    
    if (event == "PLAYER_REGEN_DISABLED") then
        RuneFrame:SetAlpha(0.5)
    end
    
    if (event == "PLAYER_LOGIN") then
        RuneFrame:SetAlpha(0.5)
    
        RuneFrame:SetParent(UIParent)
        RuneFrame.SetParent = function() end
            
        RuneFrame:ClearAllPoints()    
        RuneFrame:SetPoint("BOTTOM", Player, "BOTTOM", 32, -18)
        RuneFrame.SetPoint = function() end
        
        RuneFrame.SetScale = function() end

        for i = 1, 6 do
            for _, v in pairs ({
                "RuneButtonIndividual",
            }) do
                x(v, i)
                k()
            end
        end
    end
end)
        
addon:RegisterEvent("PLAYER_REGEN_ENABLED")
addon:RegisterEvent("PLAYER_REGEN_DISABLED")
addon:RegisterEvent("PLAYER_LOGIN")
